<template>
	<view class="transferanother_container">
		<view class="transferanother_top">
			<image :src="info.avatar || '../../static/user/touxiang.png'" mode=""></image>
			<view class="transferanother_box">
				<view class="transferanother_name">
					{{info.nickname}}
				</view>
				<view class="transferanother_phone">
					{{info.phone | showPhone}}
				</view>
			</view>
		</view>
		<view class="transferanother_text">
			转账金额
		</view>
		<u-form-item label="￥"><input  v-model="inputValue" placeholder="请输入转账金额" style="font-size: 32rpx;"/></u-form-item>
		
		<view :class="btnShow == true? 'transferanother_btnY' :'transferanother_btnN'" @click="sureBtn">
			转账
		</view>
	</view>
</template>

<script>
	import {tongId,change} from "../../api/tong.js"
	export default{
		data(){
			return{
				btnShow:false,
				inputValue:'',
				info:{}
			}
		},
		onLoad(val) {
			this.post(tongId,{
				user_id:uni.getStorageSync("userInfo").id,
				phone:val.phone
			}).then(res => {
				if(res.code == 1){
					this.info = res.data
				}
			})
		},
		filters:{
			showPhone(val){
				let t=""+val
				let reg=/(\d{3})\d{4}(\d{4})/;
				let te = t.replace(reg,"$1****$2")
				return te
			}
		},
		methods:{
			getData(){
				this.post(getUser,{
					user_id:uni.getStorageSync("userInfo").id
				}).then(res => {
						if(res.code == 1){
							this.memberInfo = res.data.member_info	
						}
				})
			},
			sureBtn(){
				this.post(change,{
					user_id:uni.getStorageSync("userInfo").id,
					lby:this.inputValue,
					to_user_id:this.info.id
				}).then(res => {
					if(res.code == 1){
						this.msg(res.msg)
						this.inputValue = ''
						setTimeout(()=>{
							// uni.navigateTo({
							// 	url:"/pages/tong/tong"
							// })
							uni.switchTab({
								url:"/pages/user/user"
							})
						},1500)
					}
				})
			}
		},
		watch:{
			inputValue:{
				handler(val,oldval){
					// console.log(val,oldval)
					if(val == ''){
						this.btnShow = false
					}else{
						this.btnShow = true
					}
				}
			},
			deep:true
		}
	}
</script>

<style lang="scss" scoped>
	.transferanother_container{
		padding: 0 30rpx;
		margin-top: 58rpx;
		.transferanother_top{
			display: flex;
			width: 690rpx;
			height: 88rpx;
			image{
				width: 88rpx;
				height: 88rpx;
			}
			.transferanother_box{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				margin-left: 20rpx;
				.transferanother_name{
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: 300;
					color: #666666;
					opacity: 1;
				}
					
				.transferanother_phone{
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 300;
					color: #666666;
					opacity: 1;
				}
			}
		}
		.transferanother_text{
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 300;
			color: #666666;
			opacity: 1;
			margin-top: 60rpx;
		}
		.transferanother_btnY{
			width: 460rpx;
			height: 88rpx;
			background: #008573;
			opacity: 1;
			border-radius: 8rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 400;
			line-height: 88rpx;
			text-align: center;
			color: #FFFFFF;
			margin-left: 115rpx;
			margin-top: 68rpx;
		}
		.transferanother_btnN{
			width: 460rpx;
			height: 88rpx;
			background: #008573;
			opacity: 0.3;
			border-radius: 8rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 400;
			line-height: 88rpx;
			text-align: center;
			color: #FFFFFF;
			margin-left: 115rpx;
			margin-top: 68rpx;
		}
	}
</style>
